/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package skelbkim;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

/**
 *
 * @author laimis
 */
public class NSL extends SeleneseTestCase {

    public void setUp() throws Exception {
        setUp("http://www.nsl.lt/", "*firefox");
    }

    public void newNotation(String noticeText, String phone, String name, String noticeTitle, String email) throws Exception {
        selenium.open("/?view=post&postevent=&cityid=1&lang=en");
        if (isPageLoude()) {
            selenium.click("//td[@id='content']/ul/li[15]/a");
            selenium.waitForPageToLoad("10000");
            selenium.click("//td[@id='content']/ul/li[4]/a");
            selenium.waitForPageToLoad("10000");
            selenium.type("adtitle", noticeTitle);
            selenium.type("addesc", noticeText);
            selenium.select("arealist", "label=Klaipėda");
            selenium.type("email", email);
            selenium.type("telefonas", phone);
            selenium.type("vardas", name);
            selenium.click("agree");
            selenium.click("//table[3]/tbody/tr/td/form/table/tbody/tr/td/button");
        }
        selenium.stop();
    }

    private boolean isPageLoude() {
        boolean result = true;
        while (!selenium.isElementPresent("//table[2]/tbody/tr/td[3]/table/tbody/tr/td/table[3]/tbody/tr/td/ul/li[15]/a")) {
            selenium.waitForPageToLoad("5000");
        }
        return result;
    }
}

